﻿//
// WorkflowSharp.Dom.ExecuteNode.cs
//
// Authors:
// 	Perciun Andrei (perciun.andrei@gmail.com)
//
// Copyright (C) 2008 Perciun Andrei (perciun.andrei@gmail.com)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System.Collections.Generic;

namespace WorkflowSharp.Dom
{
    using Exceptions;

    public class ExecuteNode<Action, Parent> : WorkflowNode<Parent>
    {
        private readonly Dictionary<string, object> parameters = new Dictionary<string, object>();

        internal ExecuteNode(Parent parent, string id)
            : base(parent, id)
        {
        }

        public ExecuteNode<Action, Parent> with(string name, object value)
        {
            if (parameters.ContainsKey(name))
            {
                throw new DuplicateParameterException(this, name);
            }

            parameters.Add(name, value);
            return this;
        }
    }
}
